package com.ruoyi.web.controller.maintenance;

import com.github.pagehelper.PageInfo;
import com.ruoyi.ruoyimaintenance.domain.entity.MaintenanceDeviceConfig;
import com.ruoyi.ruoyimaintenance.service.MaintenanceDeviceConfigService;
import com.ruoyi.ruoyimaintenance.service.MaintenanceLogdataService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/MaintenanceDeviceConfig")
public class MaintenanceDeviceConfigController {

    @Autowired
    MaintenanceDeviceConfigService maintenanceDeviceConfigService;

    @GetMapping("/maintenanceDeviceConfigBySearch")
    PageInfo<MaintenanceDeviceConfig> maintenanceDeviceConfigBySearch(
            @RequestParam(defaultValue = "1")Integer pageNub,
            @RequestParam(defaultValue = "10")Integer pageSize,
            @RequestParam(defaultValue = "")Integer line,
            @RequestParam(defaultValue = "")String machineNumber,
            @RequestParam(defaultValue = "")String headNumber
    ){


        return maintenanceDeviceConfigService.maintenanceDeviceConfigBySearch(pageNub,pageSize,line,machineNumber,headNumber);
    }

    @PostMapping("/addMaintenanceDeviceConfig")
    int addMaintenanceDeviceConfig(@Validated @RequestBody MaintenanceDeviceConfig maintenanceDeviceConfig){

        return maintenanceDeviceConfigService.addMaintenanceDeviceConfig(maintenanceDeviceConfig);
    }

    @PostMapping("/updateMaintenanceDeviceConfig")
    int updateMaintenanceDeviceConfig(@Validated @RequestBody MaintenanceDeviceConfig maintenanceDeviceConfig){

        return maintenanceDeviceConfigService.updateMaintenanceDeviceConfig(maintenanceDeviceConfig);
    }

    @DeleteMapping("/deleteMaintenanceDeviceConfig/{id}")
    int deleteMaintenanceDeviceConfig(@PathVariable Long id){
        return maintenanceDeviceConfigService.deleteMaintenanceDeviceConfig(id);
    }


}
